<template>
  <el-container>
    <el-header>
      <img src="../assets/title.svg" alt="title" class="title_img">
      <div class="profile"><img :src="profilePath" alt="profile" width="45px" height="45px"></div>
      <el-dropdown>
        <span class="el-dropdown-link">
          欢迎您，{{nickname}}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人信息主页</el-dropdown-item>
          <el-dropdown-item>修改个人信息</el-dropdown-item>
          <el-dropdown-item disabled>不可操作</el-dropdown-item>
          <el-dropdown-item divided>安全退出系统</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <el-badge :value="item" class="item">
        <i class="el-icon-message message"></i>
      </el-badge>
    </el-header>
    <el-container>
      <el-aside :width="asideWidth">
        <div class="collapse" ref="collapse">
          <i :class="[isCollapse ? 'el-icon-circle-plus' : 'el-icon-remove']" @click="doCollapse"></i>
        </div>
        <el-menu :collapse="isCollapse" :collapse-transition="false" :router="true" :unique-opened="true">
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-edit"></i><span slot="title">系统设置</span></template>
            <el-menu-item index="/setting/settings">通用设置</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title"><i class="el-icon-document"></i><span slot="title">订单管理</span></template>
            <el-menu-item index="/manage/orders">查看所有订单</el-menu-item>
            <el-menu-item index="/order/distribution">订单流水</el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title"><i class="el-icon-setting"></i><span slot="title">系统权限</span></template>
            <el-menu-item index="/manage/privilege">查看所有权限</el-menu-item>
            <el-menu-item index="/manage/roles">角色管理</el-menu-item>
            <el-menu-item index="/manage/permissionSet">权限集</el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title"><i class="el-icon-document"></i><span slot="title">用户管理</span></template>
            <el-menu-item index="/manage/userManage">查看所有用户</el-menu-item>
            <el-menu-item index="/user/branch">查看所有分体</el-menu-item>
            <el-menu-item index="/user/branchList">公众号审核</el-menu-item>
            <el-menu-item index="/user/account">提现账号审批</el-menu-item>
          </el-submenu>
          <!--<el-submenu v-for="(nav, index) in navMenu" :key="index" :index="index + 5 + ''">
            <template slot="title"><i class="el-icon-document"></i><span slot="title">{{nav.name}}</span></template>
            <el-menu-item v-for="(c, index) in nav.children" :key="index" :index="c.uri">{{c.name}}</el-menu-item>
          </el-submenu>-->
        </el-menu>
      </el-aside>
      <el-container ref="container">
        <el-main><router-view/></el-main>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'manage',
  data () {
    return {
      item: 15,
      isCollapse: false,
      asideWidth: '240px',
      profilePath: '',
      nickname: '',
      navMenu: []
    }
  },
  methods: {
    doCollapse () {
      this.isCollapse = !this.isCollapse
      if (this.isCollapse) {
        this.asideWidth = '64px'
      } else {
        this.asideWidth = '240px'
      }
    }
  },
  mounted () {
    this.$refs.container.$el.style.height = document.body.clientHeight - 60 + 'px'
    window.onresize = () => {
      this.$refs.container.$el.style.height = document.body.clientHeight - 60 + 'px'
    }
  },
  created () {
    let data = JSON.parse(window.sessionStorage.getItem('profile'))
    this.profilePath = data.pro
    this.nickname = data.nickname
    this.navMenu = JSON.parse(window.sessionStorage.getItem('navMenu'))
  }
}
</script>

<style scoped>
  .el-container{
    overflow-y: auto;
  }
  .el-header{
    border-bottom: 1px solid #e6e6e6;
  }
  .title_img{
    margin-top: 11px;
  }
  .el-dropdown{
    line-height: 60px;
    float: right;
  }
  .item{
    float: right;
    margin-right: 50px;
    margin-top: 20px;
    display: inline;
  }
  .message{
    font-size: 18px;
  }
  .el-aside{
    padding-top: 30px;
    border-right: 1px solid #e6e6e6;
    overflow-x: hidden;
    transition: width .5s;
  }
  .el-menu{
    border-right: none;
  }
  .el-main{
    background-color: #F2F6FC;
    box-shadow: inset 0 0 10px #C0C4CC;
    display: block;
  }
  .profile{
    width: 45px;
    height: 45px;
    margin: 8px 20px 7px;
    border-radius: 100%;
    float: right;
    overflow: hidden;
    box-shadow: 0 0 5px #eee;
  }
  .collapse{
    text-align: center;
    font-size: 25px;
    color: #606266;
    padding-bottom: 10px;
  }
  .collapse i{
    cursor: pointer;
  }
</style>
